/*!
 @file ECDialogLineRecorder.h
 @framework ECCoreLibrary

 @author Created by Matt Austin on 4/28/14.
 @copyright Copyright (c) 2014 EnglishCentral, Inc. All rights reserved.
 
 @internal 
*/

#import <Foundation/Foundation.h>
#import <AVFoundation/AVFoundation.h>
//#import "SpeakMetaModel.h"
#import "MujiDubEnums.h"


//MujiDubRecorder

@class MujiDubFilePathUtility;

@protocol MujiDubRecorderDelegate;
@protocol MujiDubRecorderDataSource;

#pragma clang diagnostic ignored "-Wdocumentation"


/*!
 @class        ECDialogLineRecorder
 @abstract     This class provides specific functionality for recording a dialog line.
 */
@interface  MujiDubRecorder: NSObject <AVAudioRecorderDelegate>

/*!
 @property  dialogLineModel
 */
//@property (nonatomic, strong)  ECDialogLineModel *dialogLineModel;

/*!
 @property  sessionDate
 */
@property (nonatomic, strong)  NSDate *sessionDate;

/*!
 @property  recordingSettings
 */
@property (nonatomic, strong)  NSDictionary *recordingSettings;

/*!
 @property  delegate
 */
@property (nonatomic, weak)  id<MujiDubRecorderDelegate> delegate;

/*!
 @property  wavFilePath
 */
@property (nonatomic, readonly, copy)  NSString *wavFilePath;

/*!
 @property  dataSource
 */
@property (nonatomic, weak)  id<MujiDubRecorderDataSource> dataSource;

/*!
 @property  audioRecorder
 */
@property (nonatomic, readonly, strong)  AVAudioRecorder *audioRecorder;

/*!
 @property  recordingState
 */
@property (nonatomic, readonly)  MujiDubDialogLineRecordingState recordingState;

/*!
 @property  maxRecordingDuration
 */
@property (nonatomic, assign)  NSTimeInterval maxRecordingDuration;

/*!
 @property  recordingError
 */
@property (nonatomic, readonly, strong)  NSError *recordingError;

/*!
 @property  activityID
 */
@property (nonatomic, strong) NSNumber *activityID;


/*!
 @method    initWithDialogLineModel:recordAudioToDirectoryPath:sessionDate:
 @abstract  The default initializer to create new instances of ECDialogLineRecorder.
 
 * @param     dialogLineModel
 * @param     directoryPath
 * @param     sessionDate
 * @return    A new instance of ECDialogLineRecorder
 */

- (id)initWithInfo:(NSDictionary *)info path:(NSString *)directoryPath userId:(NSString *)userId;


//- (id)initWithDialogLineModel:(SpeakMetaModel*) model path:(NSString *)directoryPath;


/*!
 @method    startRecording
 @abstract  Starts recording audio input.
 */
- (void)startRecording;


/*!
 @method    stopRecording
 @abstract  Stops recording audio input.
 */
- (void)stopRecording;


/*!
 @method    cancelRecording
 @abstract  Cancels the current recording audio input.
 */
- (void)cancelRecording;

/*!
 @method    pauseRecording
 @abstract  Pauses the current recording.
 */
- (void)pauseRecording;

/*!
 @method    didRecordingReachMaxDuration
 @abstract  Indicates if the max recording duration was reached.
 
 @return    YES if the max recording duration was reached, otherwise NO.
 */
- (BOOL)didRecordingReachMaxDuration;

@end



/*!
 @protocol  ECDialogLineRecorderDelegate
 */
@protocol MujiDubRecorderDelegate <NSObject>



@optional

/*!
 * @method    dialogLineRecorder:canDeviceRecord:
 * @abstract  Indicates if the current device is capable of recording.
 
 * @param     recorder
 * @param     canRecord
 */
- (void)dialogLineRecorder:(MujiDubRecorder *)recorder
           canDeviceRecord:(BOOL)canRecord;


@required

/*!
 @method dialogLineRecorder:didFinishRecordingForDialogLineModel:withState:error:
 @abstract  Alerts the delegate that recording has finished.
 
 @param     dialogLineRecorder
 @param     dialogLineModel
 @param     state
 @param     error
 */
//- (void)dialogLineRecorder:(ECDialogLineRecorder *)dialogLineRecorder
//didFinishRecordingForDialogLineModel:(ECDialogLineModel *)dialogLineModel
 //                withState:(ECDialogLineRecordingState)state
  //                   error:(NSError *)error;


/*
 @method    dialogLineRecorderDidBeginInterruptions:
 @abstract  Callback to alert delegate of an interruption.
 
 @param     recorder
 */
- (void)dialogLineRecorderDidBeginInterruption:(MujiDubRecorder *)recorder;
- (void)dialogLineRecorder:(MujiDubRecorder *)dialogLineRecorder
                withState:(MujiDubDialogLineRecordingState)state
                   error:(NSError *)error;

/*!
 @method    dialogLineRecorderDidEndInterruptions:
 @abstract  Alerts the delegate to the end of an interruption.
 
 @param     recorder
 @param     flags
 */
- (void)dialogLineRecorderDidEndInterruption:(MujiDubRecorder *)recorder;


@end



/*!
 @protocol  ECDialogLineRecorderDataSource
 */
@protocol MujiDubRecorderDataSource <NSObject>


@required

/*!
 @method    enableMeteringForDialogLineRecorder:
 @abstract  Asks the data source to enable metering.
 
 @param     recorder
 @return    YES to enable metering, otherwise NO.  Default is set to return NO.
 */
- (BOOL)enableMeteringForDialogLineRecorder:(MujiDubRecorder *)recorder;


@end
